import React from 'react'
import {HashRouter as Router, Switch, Route, Redirect} from "react-router-dom"
import Detail from '../news/Detail'
import News from '../news/News'
import Login from "../views/login/Login"
import NewsSandBox from "../views/sandbox/NewsSandBox"

export default function IndexRouter() {
  return (
    <Router> 
      <Switch>
        <Route  path="/login" component={Login} />
        <Route  path="/news" component={News} />
        <Route  path="/detail/:id" component={Detail} />
        {/* <Route path="/" component={NewsSandBox} /> */}
        <Route path="/" render={() => 
          localStorage.getItem("token")?
          <NewsSandBox></NewsSandBox>:
          <Redirect to="/login" />
        } />
      </Switch>
    </Router>
  )
}
